function f_check_diy_info()
{
    #从dbadb_db的表读取记录, 该端口是否要求定制化限制延迟时间. ${t_state_task}这个表配置了端口对应的最大延迟时间, 可以手动更新这个表
    declare __ _get_repl_time_ _get_repl_time diy_info_for_dbadb diy_for_tool fun_name
    fun_name="f_check_diy_info"
    [ "${execute}x" == "0x" ] && return 0 #在测试环境测试就直接返回, 只有开始在线上跑才开始执行如下代码
    diy_for_tool="${1}"
    [ -n "${user_order_id}" ] && order_opt="and order_id = ${user_order_id}" #如果使用了工单号参数就对工单维度进行判断
    __="select concat(chunk_size,':::',run_state,':::',repl_time,':::',user_mail) from ${t_state_task} 
        where port = ${mysql_port} ${order_opt} order by id desc limit 1;"
    diy_info_for_dbadb="$(${mysql_comm_dbadb} -NBe "${__}" 2>&1|sed '/Using a password/d')" && exe_state="${?}" || exe_state="${?}"
    [ "${exe_state}x" != "0x" ] && { f_exe_sql_to_dbadb "${__}" "f_check_diy_info" || true;}
    _get_repl_time_="$(awk -F::: '{print $3}' <<< "${diy_info_for_dbadb}")"
    if [ -z "${_get_repl_time_}" ]
    then #先按照工单号维度去查记录, 如果没有再按照端口维度去查
        __="select concat(chunk_size,':::',run_state,':::',repl_time,':::',user_mail) from ${t_state_task} 
            where port=${mysql_port} and order_id=id order by id desc limit 1;"
        diy_info_for_dbadb="$(${mysql_comm_dbadb} -NBe "${__}" 2>&1|sed '/Using a password/d')" && exe_state="${?}" || exe_state="${?}"
        [ "${exe_state}x" != "0x" ] && { f_exe_sql_to_dbadb "${__}" "f_check_diy_info" || true;}
        _get_repl_time="$(awk -F::: '{print $3}' <<< "${diy_info_for_dbadb}")"
        [ -n "${_get_repl_time}" ] && check_slave_repl="all"                                                       #都检查哪些从库是否有延迟
    else
        _get_repl_time="${_get_repl_time_}"
    fi

    if [ "$(sed 's/[0-9]//g' <<< "${_get_repl_time}")x" == "x" ] && [ -n "${_get_repl_time}" ]
    then #如果非空, 则表示该端口要求所有节点都检查延迟, 且都不能超过设置的值
        max_repl_time="${_get_repl_time}"                                            #允许从库最大延迟的秒数
        if [ "${max_chunk_size}x" != "$(awk -F::: '{print $1}' <<< "${diy_info_for_dbadb}")x" ]
        then
            max_chunk_size="$(awk -F::: '{print $1}' <<< "${diy_info_for_dbadb}")"        #chunk_size大小
            max_chunk_size_tmp="${max_chunk_size}" #这个变量的作用是避免chunk size提升的太多, 限制最大提升100%
        fi
        user_mail_addr="$(awk -F::: '{print $4}' <<< "${diy_info_for_dbadb}")"        #操作者的邮箱地址
        global_osc_run_state="$(awk -F::: '{print $2}' <<< "${diy_info_for_dbadb}")"  #osc运行状态, 0表示正常, 1表示stop
    elif [ "$(sed 's/[0-9]//g' <<< "${_get_repl_time}")x" != "x" ]
    then
        f_logging "ERROR:${fun_name}" "访问${dbadb_db}的${dbadb_db}.${t_state_task}表异常"
        return 0
    fi

    if [ "${diy_for_tool}x" == "gh-ostx" ]
    then #ghost才支持动态调整chunk size
        [ -z "${max_chunk_size_tmp}" ] && max_chunk_size_tmp="${max_chunk_size}" #这个变量的作用是避免chunk size提升的太多, 限制最大提升100%
        _max_chunk_size_="${max_chunk_size}"                                     #临时变量, 判断chunk size是否改变了, 要是改变了就更新库里的记录
        [ -f "${max_thread_file}" ] && max_thread_running="$(grep -P "^[1-9][0-9]{0,}$" ${max_thread_file}|tail -1)" || true  #动态获取活跃连接数, 以此动态控制chunk size
        if [ -n "${max_thread_running}" ]
        then
            [ -f "${max_thread_file}" ] && echo "" > ${max_thread_file}
            max_thread_running_tmp=1
        else
            max_thread_running=6 && max_thread_running_tmp=0
        fi

        if [ "${max_thread_running}" -le 5 ]
        then #活跃连接数小于5 提升200
            max_chunk_size="$(awk -v max="${max_chunk_size_tmp}" '{if($1 >= max * 2 - 200){print max * 2} else{print $1 + 200}}' <<< "${max_chunk_size}")"
        elif [ "${max_thread_running}" -le 20 ] && [ "${max_thread_running}" -gt 15 ] && [ "${max_chunk_size}x" != "100x" ]
        then #活跃连接数大于15 降低10%
            max_chunk_size="$(awk '{printf ("%0.f\n", int($1 - $1 * 0.1) / 100)}' <<< "${max_chunk_size}"|awk '{if ($1 > 5){print $1 * 100}else {print 500}}')"
        elif [ "${max_thread_running}" -le 25 ] && [ "${max_thread_running}" -gt 20 ] && [ "${max_chunk_size}x" != "100x" ]
        then #活跃连接数大于20 降低30%
            max_chunk_size="$(awk '{printf ("%0.f\n", int($1 - $1 * 0.3) / 100)}' <<< "${max_chunk_size}"|awk '{if ($1 > 3){print $1 * 100}else {print 300}}')"
        elif [ "${max_thread_running}" -le 30 ] && [ "${max_thread_running}" -gt 25 ] && [ "${max_chunk_size}x" != "100x" ]
        then #活跃连接数大于25 降低50%
            max_chunk_size="$(awk '{printf ("%0.f\n", int($1 - $1 * 0.5) / 100)}' <<< "${max_chunk_size}"|awk '{if ($1 > 0){print $1 * 100}else {print 100}}')"
        elif [ "${max_thread_running}" -gt 30 ] && [ "${max_chunk_size}x" != "100x" ]
        then #活跃连接数大于30 强制为chunk size=10
            max_chunk_size="100"
        elif [ "${max_chunk_size_tmp}" -gt "${max_chunk_size}" ] && [ "${max_thread_running_tmp}x" == "1x" ]
        then #活跃连接数恢复正常就提升200
            max_chunk_size="$(awk -v max="${max_chunk_size_tmp}" '{if($1 >= max - 200){print max} else{print $1 + 200}}' <<< "${max_chunk_size}")"
        fi
    fi

    if [ -z "${_get_repl_time_}" ] && [ "$(grep -ic "^alter_table" <<< "${mode_opt}")x" == "1x" ]
    then #只有改表才会写这个记录
        declare _id_ _id
        _id="$(${mysql_comm_dbadb} -NBe "select count(*)+100 from ${t_state_task};" 2>/dev/null)" && exe_state="${?}" || exe_state="${?}"
        [ "${exe_state}x" != "0x" ] && { f_exe_sql_to_dbadb "select count(*)+100 from ${t_state_task};" "f_check_diy_info" || _id=10000;}
        [ -z "${user_order_id}" ] && user_order_id_mark=0 #如果没有指定工单号, 就用id作为工单号
        for ((_id_=1; _id_<=${_id}; _id_++))
        do #再这个表写一行记录, 方便改表进程动态调整一些参数, dba可以维护这个表的对应值, 使改表任务的相关配置动态生效
            [ "${user_order_id_mark}x" == "0x" ] && user_order_id=${_id_} #用id作为工单号
            __="insert into ${t_state_task}(id,order_id,user_mail,port,chunk_size,run_state,repl_time,remarks) select ${_id_},${user_order_id},"
            if [ -z "${global_osc_run_state}" ]
            then
                __="${__} '${g_user_mail_addr}',${mysql_port},1000,0,60,'临时记录工单完成会删除';"
            else
                __="${__} '${g_user_mail_addr}',${mysql_port},${max_chunk_size},${global_osc_run_state},${max_repl_time},'临时记录工单完成会删除';"
            fi
            if [ "${_id_}x" != "${_id}x" ]
            then
                ${mysql_comm_dbadb} -NBe "${__}" >/dev/null 2>&1 && break || true #写成功就退出循环, 这个目的是节省自增id
            else
                f_exe_sql_to_dbadb "${__}" "f_check_diy_info" || true
            fi
        done
        unset _id_ _id user_order_id_mark
    elif [ "${_max_chunk_size_}x" != "${max_chunk_size}x" ] && [ "${diy_for_tool}x" == "gh-ostx" ]
    then
        __="update ${t_state_task} set chunk_size = ${max_chunk_size} where port = ${mysql_port} and order_id = ${user_order_id};"
        f_exe_sql_to_dbadb "${__}" "f_check_diy_info" || true
    fi
    return 0
}

